<style>
    #container{
        padding: 0px;
        border-radius:0px;
        border-width:0px;
    }
</style>
<form class="layui-form seller-alone-form" action="" method="post">

    <input type="hidden" name="id" value="{$info.id}">

    <div class="layui-form-item">
        <label class="layui-form-label"><i class="required-color">*</i>文章分类：</label>
        <div class="layui-input-inline seller-inline-5">
            <select name="type_id" lay-verify="required" style="z-index: 5">
                <option value="{$info.type_id}">{$info.type_name}</option>
            </select>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label"><i class="required-color">*</i>文章标题：</label>
        <div class="layui-input-inline seller-inline-5">
            <input type="text" name="title" value="{$info.title}" required  lay-verify="required" placeholder="请输入文章标题" autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label"><i class="required-color">*</i>封面图：</label>
        <div class="layui-input-inline seller-inline-5">
            {ZlServer:image id='img' name='cover' required lay-verify='required' value="$info['cover']"/}
        </div>
    </div>

    <div class="layui-form-item layui-form-text" >
        <label class="layui-form-label"><i class="required-color">*</i>文章内容：</label>
        <div class="layui-input-inline" style="z-index: 1">
            <textarea id="container" name="content" style="width:100%;height:300px;" required  lay-verify="required" type="text/plain" class="layui-textarea">{$info.content}</textarea>
        </div>
    </div>

    <div class="layui-form-item" style="margin: 20px;">
        <label class="layui-form-label">是否发布：</label>
        <div class="layui-input-block">
            <input type="radio" name="is_pub" value="1" {eq name="$info.is_pub" value="1"}checked{/eq} title="立即发布">
            <input type="radio" name="is_pub" value="2" {eq name="$info.is_pub" value="2"}checked{/eq} title="暂不发布">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label"><i class="required-color">*</i></label>
        <div class="layui-input-inline seller-inline-2">
            <input type="text" name="sort" value="{$info.sort}" required  lay-verify="required" placeholder="从小到大排列" autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            {:zlserverToken()}
            <button id="article_edit_save" type="button" class="layui-btn" lay-submit lay-filter="save">保存</button>
        </div>
    </div>
</form>

<script type="text/javascript">
    var ue = UE.getEditor('container');
</script>

<script>
    layui.use(['form'], function () {
        var form = layui.form;
        form.render();
  
        //保存用户
        form.on('submit(save)', function (data) {
            formData = data.field;
            if (!formData) {
                layer.msg('请先完善数据', { time: 1300 });
                return false;
            }

            $("#article_edit_save").addClass("layui-btn-disabled");
            $('#article_edit_save').attr("disabled", true);

            $.ajax({
                type: 'post',
                url: '{:url("Article/edit")}',
                data: formData,
                dataType: 'json',
                success: function (e) {
                    if (e.status === true) {
                        layer.open({
                            type: 1
                            , offset: 'auto'
                            , id: 'layerDemoAuto'
                            , content: '<div style="padding: 20px 100px;">' + e.msg + '</div>'
                            , btn: '关闭'
                            , btnAlign: 'c' //按钮居中
                            , shade: 0.3 //不显示遮罩
                            , yes: function () {
                                parent.layui.admin.events.changeTabAndRefresh('/manage/article/index.html');
                            }, close: function () {
                                console.log('close');
                            },end: function() {
                                parent.layui.admin.events.changeTabAndRefresh('/manage/article/index.html');
                            }
                        });
                    } else {
                        $("#article_edit_save").removeClass("layui-btn-disabled");
                        $('#article_edit_save').removeAttr("disabled");
                        layer.msg(e.msg, { time: 1300 });
                    }
                }
            });
            return false;
        });
    });
</script>